<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%
	String id = request.getParameter("id");
%>
<html>
	<head>
		  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    	  <meta http-equiv="X-UA-Compatible" content="IE=edge">
    	  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    	  <meta name="renderer" content="webkit">
    	   <link rel="stylesheet" href="${pageContext.request.contextPath}/admin/css/pintuer.css">
    	   <link rel="stylesheet" href="${pageContext.request.contextPath}/admin/css/admin.css">
    	   <script src="${pageContext.request.contextPath}/admin/js/jquery.js"></script>
    	   <script src="${pageContext.request.contextPath}/admin/js/pintuer.js"></script>  
	</head>
  <body>
   <div class="panel admin-panel margin-top">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>添加字典类型</strong></div>
  <div class="body-content">
    <form method="post" class="form-x" >   
      <input type="hidden" id="id"  value="" />  
      <div class="form-group">
        <div class="label">
          <label>字典类型名称：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" id="dicName" value="" data-validate="required:请输入字典类型名称" />         
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>字典类型编码：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" id="dicCode" value="" data-validate="required:请输入字典类型编码" />         
          <div class="tips"></div>
        </div>
      </div> 
      <div class="form-group">
        <div class="label">
          <label>排序：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" id="orderNo" value="0"  data-validate="required:,number:排序必须为数字" />
          <div class="tips"></div>
        </div>
      </div>
     <div class="form-group">
        <div class="label">
          <label>字典类型描述：</label>
        </div>
        <div class="field">
          <input type="text" class="input" id="description" style="height:120px" value=""/>        
        </div>
      </div>
     <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button id="save" class="button bg-main icon-check-square-o" type="button"> 提交</button>
          <button id="cancel" class="button bg-main icon-fast-forward" type="button"> 返回</button>
        </div>
      </div>
    </form>
  </div>
</div>
  </body>
<script type="text/javascript">
  //执行操作加载服务
  $(function (){
	//执行ajax操作
	$.ajax({
	 	type:'post',
	 	url:'${pageContext.request.contextPath}/dictionaryType/load',
	 	data:{id:"<%=id%>"},
	 	dataType:'json',
	 	cache:false,
	 	success:function(data)
	 	{	
	 		if(data.success)
	 		{
	 			$("#id").val(data.entity.id);
	 			$("#dicName").val(data.entity.dicName);
	 	  		$("#dicCode").val(data.entity.dicCode);
	 	  	    $("#dicStatus").val(data.entity.dicStatus);
	 	  		$("#orderNo").val(data.entity.orderNo);
	 	  		$("#description").val(data.entity.description);
	 		}
	 		else
	 		{
	 			alert(data.message);
	 		}
	 	},
	 	error:function(data)
	 	{
	 		alert('系统出现异常!');
	 	}
	});
	});
  
  	 //按钮提交操作服务进行保存信息
  	 $("#save").click(function(){
  		 
  		var id = $("#id").val();
  		var dicName =  $("#dicName").val();
  		var dicCode =  $("#dicCode").val();
  		var dicStatus = $("#dicStatus").val();
  		var orderNo = $("#orderNo").val();
  		var description = $("#description").val();
  		
  		//执行ajax操作
  		$.ajax({
  		 	type:'post',
  		 	url:'${pageContext.request.contextPath}/dictionaryType/doEdit',
  		 	data:{
  		 		   "id":id,
  		 		   "dicName":dicName,
  		 		   "dicCode":dicCode,
  		 		   "orderNo":orderNo,
  		 		   "description":description
  		 		 },
  		 	dataType:'json',
  		 	cache:false,
  		 	success:function(data)
  		 	{	
  		 		if(data.success)
  		 		{
  		 			alert(data.message);
  		 			window.location.href = '${pageContext.request.contextPath}/dictionaryType';
  		 		}
  		 		else
  		 		{
  		 			alert(data.message);
  		 		}
  		 	},
  		 	error:function(data)
  		 	{
  		 		alert('系统出现异常!');
  		 	}
  		});
  	 });
  	 
  	 //取消按钮进行直接取消保存信息操作
  	 $("#cancel").click(function(){
  	 		location.href="${pageContext.request.contextPath}/dictionaryType/";
  	 })
  </script>
</html>
